#!/bin/sh

cd `dirname $0`
pwd=`mysql -udome -pdome --skip-column-names --default-character-set=utf8 < genpwd.sql`
echo $pwd > changepwd.log
mysql -udome -pdome dome -e "update user set passwd=sha1('$pwd');"
mailcontent=`cat mail.changepwd.txt`
datestr=`date "+%Y-%m-%d %H:%M:%S"`

echo "${mailcontent/\{pwd\}/$pwd}" | mail -r "密码更新<demoman@163.net>" -s "【$datestr】密码更新" -c 'abcs@163.net'
